package com.joysuch.wwyt.monitoringcenter.bean;

import com.google.common.collect.Lists;
import com.joysuch.wwyt.bp.entity.contractor.BpContractorStaff;
import com.joysuch.wwyt.core.entity.BaseUser;
import com.joysuch.wwyt.dzhapi.bean.ApiBaseUserBean;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @Author ZhangDong
 * @Date 2020/9/17 16:38
 */
@Data
@NoArgsConstructor
public class LocateUserDetailBean {

    @ApiModelProperty("表Id--修改时传值")
    private String employeeId;
    @ApiModelProperty("人员类型，如果定位系统不存在该人员类型则会自动创建")
    private String employeeType;
    @ApiModelProperty("人员姓名,非空，目前最大长度为4")
    private String name;
    @ApiModelProperty("性别，男、女")
    private String gender;
    @ApiModelProperty("标签SN，12位")
    //3.4版本的sn需要符合一定要求,eg:1919E00F1148
    private String sn;
    @ApiModelProperty("门禁卡号，长度不超过50")
    private String cardNumber;
    @ApiModelProperty("图标ID，目前支持1-6，如果不指定，填写“默认”即可")
    private String iconID = "1";
    @ApiModelProperty("人员详情链接，用于在定位系统的定位监控页面点击人员图标时，" +
            "在气泡框中添加“详情信息”按钮，可以使用iframe嵌套显示当前链接  --非必填字段")
    ////3.4测试发现：detailUrl为空，报-90系统错。
    private String detailUrl;
    @ApiModelProperty("报警模板名称，如果不指定，填写“默认”即可")
    private String alarmTemplate = "默认";
    @ApiModelProperty("图片路径")
    private String headPic;
    @ApiModelProperty("额外字段，如果定位系统不存在该字段，会在人员类型中自动添加  --非必填字段")
    private List<LocateFieldBean> fields;

    public LocateUserDetailBean(BaseUser user) {
        this.employeeId = user.getEmployeeId();
        //员工/承揽商人员
        this.employeeType = "员工";
        this.name = user.getRealName();
        this.gender = user.getGender();
        this.sn = user.getSn();
        this.cardNumber = user.getCardNumber();
        this.detailUrl = user.getRefUrl() == null ? "" : user.getRefUrl();
        //this.headPic = user.getFacePic();
        List<LocateFieldBean> fields = Lists.newArrayList();
        fields.add(new LocateFieldBean("工号", user.getCode()));
        //职务 取工种
        fields.add(new LocateFieldBean("职务", user.getWorkType()));
        fields.add(new LocateFieldBean("部门", user.getDepartName()));
        fields.add(new LocateFieldBean("岗位编号", user.getJob() == null ? "" : user.getJob().toString()));
        fields.add(new LocateFieldBean("身份证号", user.getIdCardNo() == null ? "" : user.getIdCardNo().toString()));
        this.fields = fields;
    }

    public LocateUserDetailBean(ApiBaseUserBean user) {
        this.employeeId = user.getEmployeeId();
        //员工/承揽商人员
        this.employeeType = "员工";
        this.name = user.getRealName();
        this.gender = user.getGender();
        this.sn = user.getSn();
        this.cardNumber = user.getCardNumber();
        this.detailUrl = user.getRefUrl() == null ? "" : user.getRefUrl();
        //this.headPic = user.getFacePic();
        List<LocateFieldBean> fields = Lists.newArrayList();
        fields.add(new LocateFieldBean("工号", user.getCode()));
        //职务 取工种
        fields.add(new LocateFieldBean("职务", user.getWorkType()));
//        fields.add(new LocateFieldBean("部门", user.getDepartName()));
        fields.add(new LocateFieldBean("岗位编号", user.getJob() == null ? "" : user.getJob().toString()));
        fields.add(new LocateFieldBean("身份证号", user.getIdCardNo() == null ? "" : user.getIdCardNo().toString()));
        this.fields = fields;
    }

    public LocateUserDetailBean(BpContractorStaff staff) {
        this.employeeId = staff.getEmployeeId();
        //员工/承揽商人员
        this.employeeType = "承揽商人员";
        this.name = staff.getName();
        this.gender = staff.getGender();
        this.sn = staff.getSn();
        this.cardNumber = staff.getCardNumber();
        this.detailUrl = staff.getRefUrl();
        //this.headPic = staff.getFacePic();
//        List<LocateFieldBean> fields = Lists.newArrayList();
//        fields.add(new LocateFieldBean("工号", user.getCode()));
//        //职务 取工种
//        fields.add(new LocateFieldBean("职务", user.getWorkType()));
//        this.fields = fields;
    }

}
